<template>
  <div id="app">
    <!-- 顶部直通车 -->
    <TopBer :key="topBarKeyValue"></TopBer>
    <Header></Header>
    <router-view @fn="reloadTopBer"/>
    <Footer></Footer>
    <!-- 登录模块 -->
    <Login v-show="isShowLoginModel"></Login>
    <!-- 提示模块 -->
    <transition name='fade'>
      <Toast v-show="isShowToast"></Toast>
    </transition>
  </div>
</template>
<script>
import TopBer from './components/TopBer.vue'
import Header from './components/Header.vue'
import Footer from './components/Footer.vue'
import Login from './components/Login.vue'
import Toast from './components/Toast.vue'
import {mapState} from 'vuex'
export default{
  components: { TopBer,Header, Footer,Login,Toast },
  data(){
    return {
      topBarKeyValue:1
    }
  },
  methods:{
    reloadTopBer(){
      this.topBarKeyValue++
    }
  },
  watch:{
    "$route.path":{
      handler(newVal,oldVal){
        if(newVal!==oldVal){
          this.topBarKeyValue++
        }
      }
    }
  },
  computed:{
    ...mapState({
      isShowLoginModel:state=>state.showLoginModel.isShowLoginModel,
      isShowToast:state=>state.showToast.isShowToast
    })
  }
}
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  // text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}

.fade-enter{
  opacity: 0;
}
.fade-enter-active{
  transition: all .5s linear;
}
.fade-enter-to{
  opacity: 1;
}
.fade-leave{
  opacity: 1;
}
.fade-leave-active{
  transition: all .5s linear;
}
.fade-leave-to{
  opacity: 0;
}

</style>
